package com.itheima.spring.bestpractive.mapping;

import com.itheima.spring.bestpractive.pojo.*;
import io.swagger.v3.oas.annotations.Operation;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;
import com.itheima.spring.bestpractive.vo.resp.assessment.AssessmentIndicatorRespVo;

import java.math.BigDecimal;
import java.util.List;
import java.util.Map;

/**
 * @version 1.0
 * @author: HZY
 * @date: 2025/6/25 16:48
 * @Content: 考核
 */
@Mapper
public interface AssessmentMapping {
    @Operation(description = "获取考核指标")
    public List<AssessmentIndicator> selectAssessmentIndicatorList(AssessmentPlan assessmentPlan);

    @Operation(description = "保存考核指标结果")
    public void insertScore(@Param("indicators") List<EmployeeIndicatorScore> scores);

    @Operation(description = "获取考核结果")
    @Select("select * from assessment_result where employee_id = #{empId} and plan_id = #{planId}")
    public AssessmentResult selectAssessmentResult(long empId,long planId);

    @Operation(description = "获取个人考核计划")
    public List<AssessmentPlan> selectAssessmentPlanList(long empId);

    @Operation(description = "发布考核计划")
    public void insertAssessmentPlan(AssessmentPlan assessmentPlanVo);

    @Operation(description = "添加考核指标")
    public void insertAssessmentIndicator(@Param("indicators") List<AssessmentIndicator> indicators);

    @Operation(description = "将指标与计划连接")
    public void insertAssessmentIndicatorPlan(@Param("planId") long planId,@Param("indicatorId") List<Long> indicatorId);

    @Operation(description = "根据考核指标的编号获取权重")
    public List<BigDecimal> selectIndicatorWeight(@Param("indicatorIds") List<Long> indicatorIds);

    @Operation(description = "将员工考核结果存入")
    public void insertAssessmentResult(AssessmentResult scores);


    @Operation(description = "删除考核计划和考核指标关联,根据级联关系，会同步删除关联表")
    public void deleteAssessmentPlanAndIndicator(@Param("planIds") List<Long> planId);

    @Operation(description = "根据计划查询指标")
    public List<Long> selectIndicatorByPlan(@Param("planIds") List<Long> planId);

    @Operation(description = "指标id删除指标")
    public void deleteIndicator(@Param("indicatorIds") List<Long> indicatorIds);

    @Operation(description = "根据指标id和用户id查询成绩")
    public List<EmployeeIndicatorScore> selectIndicatorScore(@Param("indicatorIds") List<Long> indicatorIds,@Param("empId") long empId);

    @Operation(description = "根据计划名称进行模糊查询")
    public List<AssessmentPlan> selectPlanByName(@Param("planName") String planName);

    @Operation(description = "获取全部计划")
    public List<AssessmentPlan> selectAllPlan();

    @Operation(description = "根据当前时间更新计划状态")
    @Update("update assessment_plan set status = 1 where status = -1 and plan_id = #{planId}")
    public void updatePlanStatus(long planId);
    @Operation(description = "根据当前时间更新计划状态")
    @Update("update assessment_plan set status = 0 where status = 1 and plan_id = #{planId}")
    public void updatePlanStatus2(long planId);

    @Operation(description = "获取部门考核计划对应的被考核员工")
    public List<Employee> selectPlanEmp(@Param("planId") long planId);

    @Operation(description = "获取个人考核指标")
    public List<AssessmentIndicatorRespVo> selectIndicatorByEmp(@Param("planId") long planId,@Param("empId") long empId);

    @Operation(description = "更改考核结果状态")
    public void updateResultStatus(long employeeId,long planId,int status);
    public void updateResultStatus2(long employeeId,long planId,int status);

    @Operation(description = "保存异议信息")
    public void saveDisputes(long employeeId,long planId,String objectionContent);

    @Operation(description = "获取异议计划")
    public List<AssessmentPlan> getDisputes();

    @Operation(description = "获取异议计划对应的全部员工")
    public List<Employee> getDisputesEmpByPlan(long planId);

    @Operation(description = "获取员工对应计划的异议")
    public List<Disputes> getDisputesByEmpPlan(long planId,long employeeId);

    @Operation(description = "修改员工指标结果")
    public void updataIndicatorByEmpPlan(long indicatorId,long employeeId,BigDecimal score,String comment);

    @Operation(description = "修改员工计划结果")
    public void updataResultByEmpPlan(long planId,long employeeId,BigDecimal score);

    @Operation(description = "修改员工异议结果状态")
    public void updataDisputesStatus(long planId,long employeeId);

}
